home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Applications / Text / Text Editors / Alpha 5.31 Folder / Tcl / UserCode / latex.tcl < prev    next >
Encoding:
Text File  |  1993-02-11  |  52.7 KB  |  2,447 lines  |  [TEXT/ALFA]

  1. #############################################################################
  2. #
  3. # latex.tcl:  macros and bindings for LaTeX users
  4. #
  5. # -- see files 'LaTeX Help' and 'commands.tex' in the Help folder
  6. #
  7. #############################################################################
  8. #
  9. # version 1.1 and 1.2 (11/10/92) by Richard T. Austin (austin@eecs.umich.edu)
  10. # version 2.0 (1/24/93) by Tom Scavo (scavo@cie.uoregon.edu)
  11. #
  12. # If you make improvements to this file, please share them!
  13. #
  14. #############################################################################
  15.  
  16.  
  17. #############################################################################
  18. #
  19. # Flags and Variables.
  20. #
  21. #############################################################################
  22.  
  23. set true 1
  24. set false 0
  25. # set insertLatexParameter $true
  26. # set noInsertLatexParameter $false
  27.  
  28. initTclFlag useBoxMacro
  29. initTclFlag deleteObjectNoisily
  30. initTclFlag deleteEnvironmentNoisily
  31. set useBoxMacro $true
  32. set deleteObjectNoisily $false
  33. set deleteEnvironmentNoisily $true
  34. initTclVar boxMacroName
  35. set boxMacroName "boxedEPS"
  36.  
  37.  
  38. #############################################################################
  39. #
  40. # Utility Macros.
  41. #
  42. #############################################################################
  43.  
  44. # A boolean function which checks to see if there's a current selection.
  45. proc isSelection {} {
  46.     return [string length [getSelect]]
  47. }
  48.  
  49. # Select the line containing the insertion point.
  50. proc lineSelect {} {
  51.     goto [lineStart [getPos]]
  52.     nextLineSelect
  53. }
  54.  
  55. # A boolean function which takes any string and tests to see if
  56. # that string contains all whitespace characters.  Carriage returns 
  57. # are considered whitespace, as are spaces and tabs.
  58. proc isWhitespace {anyString} {
  59.     set len [string length $anyString]
  60.     for {set i 0} {$i < $len} {incr i} {
  61.         set c [string index $anyString $i]
  62.         if {($c != "\ ") && ($c != "\t") && ($c != "\r")} then {return 0}
  63.     }
  64.     return 1
  65. }
  66.  
  67. # Insert a carriage return at the insertion point if any
  68. # character preceding the insertion point (on the same line)
  69. # is a non-whitespace character.
  70. proc openingCarriageReturn {} {
  71.     set end [getPos]
  72.     set start [lineStart $end]
  73.     set text [getText $start $end]
  74.     if {![isWhitespace $text]} carriageReturn
  75. }
  76.  
  77. # Insert a carriage return at the insertion point if any
  78. # character following the insertion point (on the same line)
  79. # is a non-whitespace character.
  80. proc closingCarriageReturn {} {
  81.     set start [getPos]
  82.     set end [nextLineStart $start]
  83.     set text [getText $start $end]
  84.     if {![isWhitespace $text]} carriageReturn
  85. }
  86.  
  87. # Set up tab stop mechanism.
  88. proc gotoTabStop {directionIndicator} {
  89.     set searchResult [search -n -f $directionIndicator -m 0 -i 1 -r 0 {•} [getPos]]
  90.     if {[llength $searchResult] == 0} then {
  91.         message "tab stop not found"
  92.         return 0
  93.     } else {
  94.         goto [lindex $searchResult 0]
  95.         return 1
  96.     }
  97. }
  98. proc nextTabStop {} {
  99.     if {[gotoTabStop 1]} {deleteChar}
  100. }
  101. proc previousTabStop {} {
  102.     if {[gotoTabStop 0]} {deleteChar}
  103. }
  104.  
  105. # Insert an object at the insertion point. If there is a selection and the 
  106. # global variable deleteObjectNoisily is false, quietly delete the selection 
  107. # first (just like "paste"). Otherwise, prompt the user for the appropriate 
  108. # action. Returns true if the object is ultimately inserted, and false if the 
  109. # user cancels the operation. 
  110. proc insertObject {objectName} {
  111.     global deleteObjectNoisily
  112.     if {[isSelection]} then {
  113.         if {$deleteObjectNoisily} then {
  114.             case [askyesno "Delete selection?"] in {
  115.                 "yes" {deleteText [getPos] [selEnd]}
  116.                 "no" {backwardChar}
  117.                 "cancel" {return 0}
  118.             }
  119.         } else {
  120.             deleteText [getPos] [selEnd]
  121.         }
  122.     }
  123.     insertText $objectName
  124.     return 1
  125. }
  126.  
  127. # Insert an object at the insertion point. If there is a selection, wrap 
  128. # it inside the parameters $left and $right. Returns true if there is a 
  129. # selection (in which case it will wrap), and false otherwise. 
  130. proc wrapObject {left right} {
  131.     set currentPos [getPos]
  132.     set selected [isSelection]
  133.     if {$selected} then {
  134.         replaceText $currentPos [selEnd] $left [getSelect] $right
  135.     } else {
  136.         insertText $left "•" $right
  137.     }
  138.     goto $currentPos
  139.     nextTabStop
  140.     return $selected
  141. }
  142.  
  143. # Inserts an environment with the specified name at the insertion point. 
  144. # Preserves indentation, and positions the cursor at the beginning of the 
  145. # environment body (to be inserted by the calling procedure). If the 
  146. # parameter latexParameter is true, a LaTeX parameter is inserted and the 
  147. # cursor is positioned there instead. Deletes the current selection quietly 
  148. # if the global variable deleteEnvironmentNoisily is false; otherwise the 
  149. # user is prompted for directions. Returns true if the environment is 
  150. # ultimately inserted, and false if the user cancels the operation. 
  151. proc insertEnvironment {environmentName latexParameter} {
  152.     global deleteEnvironmentNoisily
  153.     if {[isSelection]} then {
  154.         if {$deleteEnvironmentNoisily} then {
  155.             case [askyesno "Delete selection?"] in {
  156.                 "yes" {deleteText [getPos] [selEnd]}
  157.                 "no" {backwardChar}
  158.                 "cancel" {return 0}
  159.             }
  160.         } else {
  161.             deleteText [getPos] [selEnd]
  162.         }
  163.     }
  164.     set currentPos [getPos]
  165.     openingCarriageReturn
  166.     insertText "\\begin{" $environmentName "}"
  167.     # insert optional LaTeX parameter here:
  168.     if {$latexParameter} {insertText "{•}"}
  169.     carriageReturn
  170.     tab
  171.     insertText "•"
  172.     carriageReturn
  173.     backwardChar
  174.     deleteChar
  175.     insertText "\\end{" $environmentName "}•"
  176.     closingCarriageReturn
  177.     goto $currentPos
  178.     nextTabStop
  179.     return 1
  180. }
  181.  
  182. # Insert an environment with the given name at the insertion point. If there 
  183. # is currently a selection, cut and paste it into the body of the new 
  184. # environment, indent it, and leave it highlighted. Returns true if there is 
  185. # a selection, and false otherwise. 
  186. proc wrapEnvironment {environmentName latexParameter} {
  187.     if {[isSelection]} then {
  188.         set indent [indentString [getPos]]
  189.         set text [getSelect]
  190.         deleteText [getPos] [selEnd]
  191.         insertText $indent "\r"
  192.         backwardChar
  193.         insertEnvironment $environmentName $latexParameter
  194.         if {$latexParameter} then {
  195.             insertText "•"
  196.             nextTabStop
  197.         }
  198.         lineSelect
  199.         clear
  200.         insertText $text
  201.         markHilite
  202.         shiftRightRegion
  203.         return 1
  204.     } else {
  205.         insertEnvironment $environmentName $latexParameter
  206.         return 0
  207.     }
  208. }
  209.  
  210.  
  211. #############################################################################
  212. # Paragraph Mode Macros.
  213. #
  214. #############################################################################
  215.  
  216. # Documents:
  217. proc insertDocument {documentType} {
  218.     set currentPos [getPos]
  219.     insertText "\\documentstyle\[•\]{$documentType}"
  220.     carriageReturn
  221.     insertEnvironment "document" 0
  222.     backwardChar
  223.     deleteChar
  224.     carriageReturn
  225.     insertText "•"
  226.     carriageReturn
  227.     nextTabStop
  228.     carriageReturn
  229.     goto $currentPos
  230.     nextTabStop
  231. }
  232. proc isDocumentSelected {} {
  233.     return 1
  234. }
  235. proc isEmptyFile {} {
  236.     return 1
  237. }
  238. proc wrapDocument {documentType} {
  239.     if {[isSelection]} then {
  240.         if {[isDocumentSelected]} then {
  241.             set text [getSelect]
  242.             deleteText [getPos] [selEnd]
  243.         } else {
  244.             case [askyesno "Select entire document?"] in {
  245.                 "yes" {}
  246.                 "no" {
  247.                     set text [getSelect]
  248.                     deleteText [getPos] [selEnd]
  249.                 }
  250.                 "cancel" {return 0}
  251.             }
  252.         }
  253.         set currentPos [getPos]
  254.         insertDocument $documentType
  255.         insertText "•"
  256.         nextTabStop
  257.         lineSelect
  258.         clear
  259.         insertText $text
  260.         markHilite
  261.         nextTabStop
  262.     } else {
  263.         if {![isEmptyFile]} then {
  264.             case [askyesno "Wrap existing text?"] in {
  265.                 "yes" {}
  266.                 "no" {}
  267.                 "cancel" {return 0}
  268.             }
  269.         }
  270.         insertDocument $documentType
  271.     }
  272.     return 1
  273. }
  274.  
  275. proc letter {} {
  276.     wrapDocument "letter"
  277.     message "type style option(s)"
  278. }
  279. proc article {} {
  280.     wrapDocument "article"
  281.     message "type style option(s)"
  282. }
  283. proc report {} {
  284.     wrapDocument "report"
  285.     message "type style option(s)"
  286. }
  287. proc book {} {
  288.     wrapDocument "book"
  289.     message "type style option(s)"
  290. }
  291.  
  292. proc custom {} {
  293.     catch {prompt "What document type?" "article"} documentType
  294.     if {$documentType != "cancel"} then {
  295.         wrapDocument $documentType
  296.         message "type style option(s)"
  297.     }
  298. }
  299.  
  300. # Sectioning:
  301. proc part {} {
  302.     if {[wrapObject "\\part{" "}•"]} then {
  303.         message "don't forget label"
  304.     } else {
  305.         message "type part name"
  306.     }
  307. }
  308. proc chapter {} {
  309.     if {[wrapObject "\\chapter{" "}•"]} then {
  310.         message "don't forget label"
  311.     } else {
  312.         message "type part name"
  313.     }
  314. }
  315. proc section {} {
  316.     if {[wrapObject "\\section{" "}•"]} then {
  317.         message "don't forget label"
  318.     } else {
  319.         message "type part name"
  320.     }
  321. }
  322. proc subsection {} {
  323.     if {[wrapObject "\\subsection{" "}•"]} then {
  324.         message "don't forget label"
  325.     } else {
  326.         message "type part name"
  327.     }
  328. }
  329. proc subsubsection {} {
  330.     if {[wrapObject "\\subsubsection{" "}•"]} then {
  331.         message "don't forget label"
  332.     } else {
  333.         message "type part name"
  334.     }
  335. }
  336. proc paragraph {} {
  337.     if {[wrapObject "\\paragraph{" "}•"]} then {
  338.         message "don't forget label"
  339.     } else {
  340.         message "type part name"
  341.     }
  342. }
  343. proc subparagraph {} {
  344.     if {[wrapObject "\\subparagraph{" "}•"]} then {
  345.         message "don't forget label"
  346.     } else {
  347.         message "type part name"
  348.     }
  349. }
  350.  
  351. # Definitions:
  352. proc myList {} {alertnote "Not yet implemented."}
  353. proc newcommand {} {alertnote "Not yet implemented."}
  354. proc newenvironment {} {alertnote "Not yet implemented."}
  355. proc newtheorem {} {alertnote "Not yet implemented."}
  356. proc renewcommand {} {alertnote "Not yet implemented."}
  357. proc renewenvironment {} {alertnote "Not yet implemented."}
  358.  
  359. # Text Style:
  360. proc roman {} {
  361.     if {[wrapObject "{\\rm " "}•"]} then {
  362.         message "roman text set"
  363.     } else {
  364.         message "enter roman text"
  365.     }
  366. }
  367. proc bold {} {
  368.     if {[wrapObject "{\\bf " "}•"]} then {
  369.         message "bold text set"
  370.     } else {
  371.         message "enter bold text"
  372.     }
  373. }
  374. proc italic {} {
  375.     if {[wrapObject "{\\it " "\/}•"]} then {
  376.         insertText "•"
  377.         backwardChar
  378.         backwardChar
  379.         backwardCharSelect
  380.         backwardCharSelect
  381.     } else {
  382.         forwardCharSelect
  383.         forwardCharSelect
  384.     }
  385.     message "italic correction?"
  386. }
  387. proc emphatic {} {
  388.     if {[wrapObject "{\\em " "\/}•"]} then {
  389.         insertText "•"
  390.         backwardChar
  391.         backwardChar
  392.         backwardCharSelect
  393.         backwardCharSelect
  394.     } else {
  395.         forwardCharSelect
  396.         forwardCharSelect
  397.     }
  398.     message "italic correction?"
  399. }
  400. proc slanted {} {
  401.     if {[wrapObject "{\\sl " "\/}•"]} then {
  402.         insertText "•"
  403.         backwardChar
  404.         backwardChar
  405.         backwardCharSelect
  406.         backwardCharSelect
  407.     } else {
  408.         forwardCharSelect
  409.         forwardCharSelect
  410.     }
  411.     message "italic correction?"
  412. }
  413. proc sansSerif {} {
  414.     if {[wrapObject "{\\sf " "}•"]} then {
  415.         message "sans serif text set"
  416.     } else {
  417.         message "enter sans serif text"
  418.     }
  419. }
  420. proc smallCaps {} {
  421.     if {[wrapObject "{\\sc " "}•"]} then {
  422.         message "small caps text set"
  423.     } else {
  424.         message "enter small caps text"
  425.     }
  426. }
  427. proc typewriter {} {
  428.     if {[wrapObject "{\\tt " "}•"]} then {
  429.         message "typewriter text set"
  430.     } else {
  431.         message "enter typewriter text"
  432.     }
  433. }
  434.  
  435. # Text Size:
  436. proc tiny {} {
  437.     if {[wrapObject "{\\tiny " "}•"]} then {
  438.         message "tiny text set"
  439.     } else {
  440.         message "enter tiny text"
  441.     }
  442. }
  443. proc smallest {} {
  444.     if {[wrapObject "{\\scriptsize " "}•"]} then {
  445.         message "scriptsize text set"
  446.     } else {
  447.         message "enter scriptsize text"
  448.     }
  449. }
  450. proc smaller {} {
  451.     if {[wrapObject "{\\footnotesize " "}•"]} then {
  452.         message "footnotesize text set"
  453.     } else {
  454.         message "enter footnotesize text"
  455.     }
  456. }
  457. proc small {} {
  458.     if {[wrapObject "{\\small " "}•"]} then {
  459.         message "small text set"
  460.     } else {
  461.         message "enter small text"
  462.     }
  463. }
  464. proc normal {} {
  465.     if {[wrapObject "{\\normalsize " "}•"]} then {
  466.         message "normalsize text set"
  467.     } else {
  468.         message "enter normalsize text"
  469.     }
  470. }
  471. proc large {} {
  472.     if {[wrapObject "{\\large " "}•"]} then {
  473.         message "large text set"
  474.     } else {
  475.         message "enter large text"
  476.     }
  477. }
  478. proc larger {} {
  479.     if {[wrapObject "{\\Large " "}•"]} then {
  480.         message "Large text set"
  481.     } else {
  482.         message "enter Large text"
  483.     }
  484. }
  485. proc largest {} {
  486.     if {[wrapObject "{\\LARGE " "}•"]} then {
  487.         message "LARGE text set"
  488.     } else {
  489.         message "enter LARGE text"
  490.     }
  491. }
  492. proc huge {} {
  493.     if {[wrapObject "{\\huge " "}•"]} then {
  494.         message "huge text set"
  495.     } else {
  496.         message "enter huge text"
  497.     }
  498. }
  499. proc gigantic {} {
  500.     if {[wrapObject "{\\Huge " "}•"]} then {
  501.         message "Huge text set"
  502.     } else {
  503.         message "enter Huge text"
  504.     }
  505. }
  506.  
  507. # International:  not yet implemented.
  508.  
  509. # Environments:
  510. proc enumerate {} {
  511.     catch {prompt "enumerate:  how many items?" 3} numberItems
  512.     if {$numberItems != "cancel"} then {
  513.         set currentPos [getPos]
  514.         if {[insertEnvironment "enumerate" 0]} then {
  515.             item
  516.             insertText "  •"
  517.             for {set i 1} {$i < $numberItems} {incr i} {
  518.                 carriageReturn
  519.                 carriageReturn
  520.                 item
  521.                 insertText "  •"
  522.             }
  523.             goto $currentPos
  524.             nextTabStop
  525.             message "Type first item"
  526.         }
  527.     }
  528. }
  529. proc itemize {} {
  530.     catch {prompt "itemize:  how many items?" 3} numberItems
  531.     if {$numberItems != "cancel"} then {
  532.         set currentPos [getPos]
  533.         if {[insertEnvironment "itemize" 0]} then {
  534.             item
  535.             insertText "  •"
  536.             for {set i 1} {$i < $numberItems} {incr i} {
  537.                 carriageReturn
  538.                 carriageReturn
  539.                 item
  540.                 insertText "  •"
  541.             }
  542.             goto $currentPos
  543.             nextTabStop
  544.             message "Type first item"
  545.         }
  546.     }
  547. }
  548. proc description {} {
  549.     catch {prompt "description: how many items?" 3} numberItems
  550.     if {$numberItems != "cancel"} then {
  551.         set currentPos [getPos]
  552.         if {[insertEnvironment "description" 0]} then {
  553.             item
  554.             insertText "\[•\]  •"
  555.             for {set i 1} {$i < $numberItems} {incr i} {
  556.                 carriageReturn
  557.                 carriageReturn
  558.                 item
  559.                 insertText "\[•\]  •"
  560.             }
  561.             goto $currentPos
  562.             nextTabStop
  563.             message "Type first item"
  564.         }
  565.     }
  566. }
  567.  
  568. proc insertRow {jmax} {
  569.     insertText "•"
  570.     for {set j 1} {$j < $jmax} {incr j} {
  571.         insertText " & •"
  572.     }
  573. }
  574. proc tabular {} {
  575.     catch {prompt "tabular:  how many rows?" 3} numberRows
  576.     if {$numberRows != "cancel"} then {
  577.         catch {prompt "tabular:  how many columns?" 3} numberCols
  578.         if {$numberCols != "cancel"} then {
  579.             if {[insertEnvironment "tabular" 1]} then {
  580.                 set beginArgument [getPos]
  581.                 insertText "|"
  582.                 for {set j 1} {$j <= $numberCols} {incr j} {
  583.                     insertText "c|"
  584.                 }
  585.                 set endArgument [getPos]
  586.                 nextTabStop
  587.                 insertText "\\hline"
  588.                 for {set i 1} {$i <= $numberRows} {incr i} {
  589.                     carriageReturn
  590.                     insertRow $numberCols
  591.                     insertText "  \\\\"
  592.                     carriageReturn
  593.                     insertText "\\hline"
  594.                 }
  595.                 goto $beginArgument
  596.                 setMark
  597.                 goto $endArgument
  598.                 markHilite
  599.                 message "modify argument?"
  600.             }
  601.         }
  602.     }
  603. }
  604. proc tabbing {} {alertnote "Not yet implemented."}
  605.  
  606. proc figure {} {
  607.     global useBoxMacro
  608.     global boxMacroName
  609.     if {$useBoxMacro} then {
  610.         set currentPos [getPos]
  611.         if {[insertEnvironment "figure" 0]} then {
  612.             insertText "\\centerline{\\$boxMacroName{•}}"
  613.         } else {
  614.             return
  615.         }
  616.     } else {
  617.         if {[wrapEnvironment "figure" 0]} then {
  618.             forwardChar
  619.             backwardChar
  620.             set currentPos [getPos]
  621.         } else {
  622.             set currentPos [getPos]
  623.             insertText "•"
  624.         }
  625.     }
  626.     carriageReturn
  627.     insertText "\\caption{•}"
  628.     carriageReturn
  629.     insertText "\\protect\\label{•}"
  630.     goto $currentPos
  631.     nextTabStop
  632. }
  633. proc table {} {
  634.     if {[wrapEnvironment "table" 0]} then {
  635.         forwardChar
  636.         backwardChar
  637.         set currentPos [getPos]
  638.     } else {
  639.         set currentPos [getPos]
  640.         insertText "•"
  641.     }
  642.     carriageReturn
  643.     insertText "\\caption{•}"
  644.     carriageReturn
  645.     insertText "\\protect\\label{•}"
  646.     goto $currentPos
  647.     nextTabStop
  648. }
  649. proc slide {} {
  650.     wrapEnvironment "slide" 1
  651.     message "enter colors"
  652. }
  653.  
  654. proc verbatim {} {wrapEnvironment "verbatim" 0}
  655. proc quote {} {wrapEnvironment "quote" 0}
  656. proc quotation {} {wrapEnvironment "quotation" 0}
  657. proc verse {} {wrapEnvironment "verse" 0}
  658.  
  659. proc index {} {alertnote "Not yet implemented."}
  660. proc bibliography {} {
  661.     catch {prompt "bibliography:  how many bibitems?" 3} numberItems
  662.     if {$numberItems != "cancel"} then {
  663.         if {[insertEnvironment "thebibliography" 1]} then {
  664.             set beginArgument [getPos]
  665.             insertText "99"
  666.             set endArgument [getPos]
  667.             nextTabStop
  668.             insertText "\\bibitem{•}"
  669.             carriageReturn
  670.             insertText "•"
  671.             for {set i 1} {$i < $numberItems} {incr i} {
  672.                 carriageReturn
  673.                 carriageReturn
  674.                 insertText "\\bibitem{•}"
  675.                 carriageReturn
  676.                 insertText "•"
  677.             }
  678.             goto $beginArgument
  679.             setMark
  680.             goto $endArgument
  681.             markHilite
  682.             message "modify argument?"
  683.         }
  684.     }
  685. }
  686.  
  687. proc general {} {
  688.     catch {prompt "What environment?" "center"} environmentName
  689.     if {$environmentName != "cancel"} {wrapEnvironment $environmentName 0}
  690. }
  691.  
  692. # Boxes:
  693. proc mbox {} {
  694.     if {[wrapObject "\\mbox{" "}•"]} then {
  695.         message "mbox set"
  696.     } else {
  697.         message "enter text"
  698.     }
  699. }
  700. proc fbox {} {alertnote "Not yet implemented."}
  701. proc parbox {} {alertnote "Not yet implemented."}
  702.  
  703. # Misc:
  704. proc ellipsis {} {insertObject "\\ldots"}
  705. proc sectionMark {} {insertObject "\\S"}
  706. proc paragraphMark {} {insertObject "\\P"}
  707. proc dagger {} {insertObject "\\dag"}
  708. proc dblDagger {} {insertObject "\\ddag"}
  709. proc copyright {} {insertObject "\\copyright"}
  710. proc pounds {} {insertObject "\\pounds"}
  711. proc {en-dash} {} {insertObject "--"}
  712. proc {em-dash} {} {insertObject "---"}
  713. proc texLogo {} {insertObject "\\TeX"}
  714. proc latexLogo {} {insertObject "\\LaTeX"}
  715. proc date {} {insertObject "\\today"}
  716.  
  717. proc quotes {} {
  718.     if {[wrapObject "`" "'•"]} then {
  719.         message "text quoted"
  720.     } else {
  721.         message "enter text"
  722.     }
  723. }
  724. proc dblQuotes {} {
  725.     if {[wrapObject "``" "''•"]} then {
  726.         message "text double quoted"
  727.     } else {
  728.         message "enter text"
  729.     }
  730. }
  731. proc note {} {
  732.     if {[wrapObject "\\marginpar{" "}•"]} then {
  733.         message "marginal note set"
  734.     } else {
  735.         message "enter marginal note"
  736.     }
  737. }
  738. proc footnote {} {
  739.     if {[wrapObject "\\footnote{" "}•"]} then {
  740.         message "footnote set"
  741.     } else {
  742.         message "enter footnote"
  743.     }
  744. }
  745. proc label {} {
  746.     if {[wrapObject "\\label{" "}•"]} then {
  747.         message "label defined"
  748.     } else {
  749.         message "enter label"
  750.     }
  751. }
  752. proc crossRef {} { 
  753.     if {[wrapObject "\\ref{" "}•"]} then {
  754.         message "cross-reference made"
  755.     } else {
  756.         message "enter cross-reference"
  757.     }
  758. }
  759. proc pageRef {} { 
  760.     if {[wrapObject "\\pageref{" "}•"]} then {
  761.         message "page reference made"
  762.     } else {
  763.         message "enter page reference"
  764.     }
  765. }
  766. proc citation {} {
  767.     if {[wrapObject "\\cite{" "}•"]} then {
  768.         message "citation made"
  769.     } else {
  770.         message "enter citation"
  771.     }
  772. }
  773. proc item {} {insertObject "\\item"}
  774. proc bibitem {} {
  775.     if {[wrapObject "\\bibitem{" "}•"]} then {
  776.         message "bibitem set"
  777.     } else {
  778.         message "enter bibitem"
  779.     }
  780. }
  781.  
  782.  
  783. #############################################################################
  784. # Math Mode Macros.
  785. #
  786. #############################################################################
  787.  
  788. # Modes:
  789. proc texMath {} {
  790.     if {[wrapObject "$" "$•"]} then {
  791.         message "formula set"
  792.     } else {
  793.         message "enter formula"
  794.     }
  795. }
  796. proc texDisplaymath {} {
  797.     if {[wrapObject "$$" "$$•"]} then {
  798.         message "displayed formula set"
  799.     } else {
  800.         message "enter displayed formula"
  801.     }
  802. }
  803. proc latexMath {} {
  804.     if {[wrapObject "\\( " " \\)•"]} then {
  805.         message "formula set"
  806.     } else {
  807.         message "enter formula"
  808.     }
  809. }
  810. proc latexDisplaymath {} {
  811.     if {[wrapObject "\\\[ " " \\\]•"]} then {
  812.         message "displayed formula set"
  813.     } else {
  814.         message "enter displayed formula"
  815.     }
  816. }
  817.  
  818. # Environments:
  819. proc math {} {wrapEnvironment "math" 0}
  820. proc displaymath {} {wrapEnvironment "displaymath" 0}
  821. proc equation {} {
  822.     if {[wrapEnvironment "equation" 0]} then {
  823.         forwardChar
  824.         backwardChar
  825.         set currentPos [getPos]
  826.     } else {
  827.         set currentPos [getPos]
  828.         insertText "•"
  829.     }
  830.     carriageReturn
  831.     insertText "\\label{•}"
  832.     goto $currentPos
  833.     nextTabStop
  834. }
  835. proc myArray {} {
  836.     catch {prompt "array:  how many rows?" 3} numberRows
  837.     if {$numberRows != "cancel"} then {
  838.         catch {prompt "array:  how many columns?" 3} numberCols
  839.         if {$numberCols != "cancel"} then {
  840.             if {[insertEnvironment "array" 1]} then {
  841.                 set beginArgument [getPos]
  842.                 for {set j 1} {$j <= $numberCols} {incr j} {
  843.                     insertText "c"
  844.                 }
  845.                 set endArgument [getPos]
  846.                 nextTabStop
  847.                 for {set i 1} {$i < $numberRows} {incr i} {
  848.                     insertRow $numberCols
  849.                     insertText "  \\\\"
  850.                     carriageReturn
  851.                 }
  852.                 insertRow $numberCols
  853.                 goto $beginArgument
  854.                 setMark
  855.                 goto $endArgument
  856.                 markHilite
  857.                 message "modify argument?"
  858.             }
  859.         }
  860.     }
  861. }
  862. proc eqnarray {} {
  863.     catch {prompt "eqnarray:  how many rows?" 3} numberRows
  864.     if {$numberRows != "cancel"} then {
  865.         set currentPos [getPos]
  866.         if {[insertEnvironment "eqnarray" 0]} then {
  867.             for {set i 1} {$i < $numberRows} {incr i} {
  868.                 insertRow 3
  869.                 carriageReturn
  870.                 insertText "\\label{•} \\\\"
  871.                 carriageReturn
  872.             }
  873.             insertRow 3
  874.             carriageReturn
  875.             insertText "\\label{•}"
  876.             goto $currentPos
  877.             nextTabStop
  878.         }
  879.     }
  880. }
  881. proc eqnarrayStar {} {
  882.     catch {prompt "eqnarray*:  how many rows?" 3} numberRows
  883.     if {$numberRows != "cancel"} then {
  884.         set currentPos [getPos]
  885.         if {[insertEnvironment "eqnarray*" 0]} then {
  886.             for {set i 1} {$i < $numberRows} {incr i} {
  887.                 insertRow 3
  888.                 insertText "  \\\\"
  889.                 carriageReturn
  890.             }
  891.             insertRow 3
  892.             goto $currentPos
  893.             nextTabStop
  894.         }
  895.     }
  896. }
  897.  
  898. # Formulas:
  899. proc subscript {} {
  900.     if {[wrapObject "_{" "}•"]} then {
  901.         message "subscript set"
  902.     } else {
  903.         message "enter subscript"
  904.     }
  905. }
  906. proc superscript {} {
  907.     if {[wrapObject "^{" "}•"]} then {
  908.         message "superscript set"
  909.     } else {
  910.         message "enter superscript"
  911.     }
  912. }
  913. proc fraction {} {
  914.     set currentPos [getPos]
  915.     if {[isSelection]} then {
  916.         set selection [getSelect]
  917.         set args [split $selection /]
  918.         set len [llength $args]
  919.         deleteText $currentPos [selEnd]
  920.         if {$len == 1} then {
  921.             # maybe the selection should be deleted in this case?
  922.             insertText "\\frac{" $selection "}{•}•"
  923.             goto $currentPos
  924.             nextTabStop
  925.             message "enter denominator"
  926.         } else {
  927.             set firstArg [lindex $args 0]
  928.             set restArgs [lrange $args 1 [expr $len-1]]
  929.             insertText "\\frac{" $firstArg "}{" [join $restArgs /] "}"
  930.             if {$len > 2} {message "beware of multiple /"}
  931.         }
  932.     } else {
  933.         insertText "\\frac{•}{•}•"
  934.         goto $currentPos
  935.         nextTabStop
  936.         message "enter numerator"
  937.     }
  938. }
  939. proc squareRoot {} {
  940.     if {[wrapObject "\\sqrt{" "}•"]} then {
  941.         message "square root set"
  942.     } else {
  943.         message "enter formula"
  944.     }
  945. }
  946. proc nthRoot {} {
  947.     if {[wrapObject "\\sqrt\[•\]{" "}•"]} then {
  948.         message "enter root"
  949.     } else {
  950.         message "enter root, then formula"
  951.     }
  952. }
  953. proc oneParameter {} {
  954.     catch {prompt "Command name?" "sqrt"} commandName
  955.     if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}•"}
  956. }
  957. proc twoParameters {} {
  958.     catch {prompt "Command name?" "frac"} commandName
  959.     if {$commandName != "cancel"} then {
  960.         set currentPos [getPos]
  961.         if {[insertObject "\\$commandName{•}{•}•"]} then {
  962.             goto $currentPos
  963.             nextTabStop
  964.         }
  965.     }
  966. }
  967.  
  968. # Greek:
  969. proc alpha {} {insertObject "\\alpha"}
  970. proc beta {} {insertObject "\\beta"}
  971. proc gamma {} {insertObject "\\gamma"}
  972. proc delta {} {insertObject "\\delta"}
  973. proc epsilon {} {insertObject "\\epsilon"}
  974. proc zeta {} {insertObject "\\zeta"}
  975. proc eta {} {insertObject "\\eta"}
  976. proc theta {} {insertObject "\\theta"}
  977. proc iota {} {insertObject "\\iota"}
  978. proc kappa {} {insertObject "\\kappa"}
  979. proc lambda {} {insertObject "\\lambda"}
  980. proc mu {} {insertObject "\\mu"}
  981. proc nu {} {insertObject "\\nu"}
  982. proc xi {} {insertObject "\\xi"}
  983. proc pi {} {insertObject "\\pi"}
  984. proc rho {} {insertObject "\\rho"}
  985. proc sigma {} {insertObject "\\sigma"}
  986. proc tau {} {insertObject "\\tau"}
  987. proc upsilon {} {insertObject "\\upsilon"}
  988. proc phi {} {insertObject "\\phi"}
  989. proc chi {} {insertObject "\\chi"}
  990. proc psi {} {insertObject "\\psi"}
  991. proc omega {} {insertObject "\\omega"}
  992.  
  993. proc capGamma {} {insertObject "\\Gamma"}
  994. proc capDelta {} {insertObject "\\Delta"}
  995. proc capTheta {} {insertObject "\\Theta"}
  996. proc capLambda {} {insertObject "\\Lambda"}
  997. proc capXi {} {insertObject "\\Xi"}
  998. proc capPi {} {insertObject "\\Pi"}
  999. proc capSigma {} {insertObject "\\Sigma"}
  1000. proc capUpsilon {} {insertObject "\\Upsilon"}
  1001. proc capPhi {} {insertObject "\\Phi"}
  1002. proc capPsi {} {insertObject "\\Psi"}
  1003. proc capOmega {} {insertObject "\\Omega"}
  1004.  
  1005. proc varEpsilon {} {insertObject "\\varepsilon"}
  1006. proc varTheta {} {insertObject "\\vartheta"}
  1007. proc varPi {} {insertObject "\\varpi"}
  1008. proc varRho {} {insertObject "\\varrho"}
  1009. proc varSigma {} {insertObject "\\varsigma"}
  1010. proc varPhi {} {insertObject "\\varphi"}
  1011.  
  1012. # Binary Ops:
  1013. proc plusOrMinus {} {insertObject "\\pm"}
  1014. proc minusOrPlus {} {insertObject "\\mp"}
  1015. proc multiply {} {insertObject "\\times"}
  1016. proc divide {} {insertObject "\\div"}
  1017. proc asterisk {} {insertObject "\\ast"}
  1018. proc star {} {insertObject "\\star"}
  1019. proc circle {} {insertObject "\\circ"}
  1020. proc bigCircle {} {insertObject "\\bigcirc"}
  1021. proc bullet {} {insertObject "\\bullet"}
  1022. proc centerDot {} {insertObject "\\cdot"}
  1023. proc intersection {} {insertObject "\\cap"}
  1024. proc union {} {insertObject "\\cup"}
  1025. proc logicalAnd {} {insertObject "\\wedge"}
  1026. proc logicalOr {} {insertObject "\\vee"}
  1027. proc setMinus {} {insertObject "\\setminus"}
  1028.  
  1029. # Relations:
  1030. proc notEqual {} {insertObject "\\neq"}
  1031. proc lessOrEqual {} {insertObject "\\leq"}
  1032. proc greaterOrEqual {} {insertObject "\\geq"}
  1033. proc subset {} {insertObject "\\subset"}
  1034. proc superset {} {insertObject "\\supset"}
  1035. proc subsetOrEqual {} {insertObject "\\subseteq"}
  1036. proc supersetOrEqual {} {insertObject "\\supseteq"}
  1037. proc elementOf {} {insertObject "\\in"}
  1038. proc equivalent {} {insertObject "\\equiv"}
  1039. proc similar {} {insertObject "\\sim"}
  1040. proc similarEqual {} {insertObject "\\simeq"}
  1041. proc dotEqual {} {insertObject "\\doteq"}
  1042. proc approximate {} {insertObject "\\approx"}
  1043. proc congruent {} {insertObject "\\cong"}
  1044.  
  1045. # Large Ops:
  1046. proc insertLargeOp {commandName} {
  1047.     set currentPos [getPos]
  1048.     insertText "\\$commandName"
  1049.     insertText "_{•}^{•}•"
  1050.     goto $currentPos
  1051.     nextTabStop
  1052. }
  1053. proc sum {} {insertLargeOp "sum"}
  1054. proc product {} {insertLargeOp "prod"}
  1055. proc integral {} {insertLargeOp "int"}
  1056. proc bigUnion {} {insertLargeOp "bigcup"}
  1057. proc bigIntersection {} {insertLargeOp "bigcap"}
  1058. proc bigAnd {} {insertLargeOp "bigwedge"}
  1059. proc bigOr {} {insertLargeOp "bigvee"}
  1060.  
  1061. # Arrows:
  1062. proc mapsTo {} {insertObject "\\mapsto"}
  1063. proc leftArrow {} {insertObject "\\leftarrow"}
  1064. proc rightArrow {} {insertObject "\\rightarrow"}
  1065. proc {left-rightArrow} {} {insertObject "\\leftrightarrow"}
  1066. proc dblLeftArrow {} {insertObject "\\Leftarrow"}
  1067. proc dblRightArrow {} {insertObject "\\Rightarrow"}
  1068. proc {dblLeft-rightArrow} {} {insertObject "\\Leftrightarrow"}
  1069.  
  1070. # Dots:
  1071. proc centerDots {} {insertObject "\\cdots"}
  1072. proc verticalDots {} {insertObject "\\vdots"}
  1073. proc diagonalDots {} {insertObject "\\ddots"}
  1074.  
  1075. # Symbols:
  1076. proc aleph {} {insertObject "\\aleph"}
  1077. proc emptySet {} {insertObject "\\emptyset"}
  1078. proc negation {} {insertObject "\\neg"}
  1079. proc forAll {} {insertObject "\\forall"}
  1080. proc exists {} {insertObject "\\exists"}
  1081. proc scriptL {} {insertObject "\\ell"}
  1082. proc nabla {} {insertObject "\\nabla"}
  1083. proc partial {} {insertObject "\\partial"}
  1084. proc infinity {} {insertObject "\\infty"}
  1085. proc backslash {} {insertObject "\\backslash"}
  1086. proc angle {} {insertObject "\\angle"}
  1087. proc box {} {insertObject "\\Box"}
  1088. proc diamond {} {insertObject "\\Diamond"}
  1089. proc triangle {} {insertObject "\\triangle"}
  1090.  
  1091. # Functions:  not yet implemented.
  1092.  
  1093. # Delimiters:
  1094. proc parentheses {} {
  1095.     if {[wrapObject "(" ")•"]} then {
  1096.         message "formula delimited"
  1097.     } else {
  1098.         message "enter formula"
  1099.     }
  1100. }
  1101. proc brackets {} {
  1102.     if {[wrapObject "\[" "\]•"]} then {
  1103.         message "formula delimited"
  1104.     } else {
  1105.         message "enter formula"
  1106.     }
  1107. }
  1108. proc braces {} {
  1109.     if {[wrapObject "\\\{" "\\\}•"]} then {
  1110.         message "formula delimited"
  1111.     } else {
  1112.         message "enter formula"
  1113.     }
  1114. }
  1115. proc absoluteValue {} {
  1116.     if {[wrapObject "|" "|•"]} then {
  1117.         message "formula delimited"
  1118.     } else {
  1119.         message "enter formula"
  1120.     }
  1121. }
  1122. proc otherDelims {} {
  1123.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" "braces" "angle brackets" "vertical bars" "double bars" "ceiling" "floor"} delimType
  1124.     if {$delimType != "cancel"} then {
  1125.         case $delimType in {
  1126.             "parentheses" {
  1127.                 set leftDelim "("
  1128.                 set rightDelim ")"
  1129.             }
  1130.             "brackets" {
  1131.                 set leftDelim "\["
  1132.                 set rightDelim "\]"
  1133.             }
  1134.             "braces" {
  1135.                 set leftDelim "\\\{"
  1136.                 set rightDelim "\\\}"
  1137.             }
  1138.             "{angle brackets}" {
  1139.                 set leftDelim "\\langle"
  1140.                 set rightDelim "\\rangle"
  1141.             }
  1142.             "{vertical bars}" {
  1143.                 set leftDelim "|"
  1144.                 set rightDelim "|"
  1145.             }
  1146.             "{double bars}" {
  1147.                 set leftDelim "\\|"
  1148.                 set rightDelim "\\|"
  1149.             }
  1150.             "ceiling" {
  1151.                 set leftDelim "\\lceil"
  1152.                 set rightDelim "\\rceil"
  1153.             }
  1154.             "floor" {
  1155.                 set leftDelim "\\lfloor"
  1156.                 set rightDelim "\\rfloor"
  1157.             }
  1158.             default {
  1159.                 alertnote "\"$delimType\" not recognized"
  1160.                 return
  1161.             }
  1162.         }
  1163.         if {[wrapObject "$leftDelim" "$rightDelim•"]} then {
  1164.             message "formula delimited"
  1165.         } else {
  1166.             message "enter formula"
  1167.         }
  1168.     }
  1169. }
  1170.  
  1171. proc {half-openInterval} {} {
  1172.     if {[wrapObject "(" "\]•"]} then {
  1173.         message "formula delimited"
  1174.     } else {
  1175.         message "enter formula"
  1176.     }
  1177. }
  1178. proc {half-closedInterval} {} {
  1179.     if {[wrapObject "\[" ")•"]} then {
  1180.         message "formula delimited"
  1181.     } else {
  1182.         message "enter formula"
  1183.     }
  1184. }
  1185.  
  1186. proc bigParentheses {} {
  1187.     if {[wrapObject "\\left(" "\\right)•"]} then {
  1188.         message "formula delimited"
  1189.     } else {
  1190.         message "enter formula"
  1191.     }
  1192. }
  1193. proc bigBrackets {} {
  1194.     if {[wrapObject "\\left\[" "\\right\]•"]} then {
  1195.         message "formula delimited"
  1196.     } else {
  1197.         message "enter formula"
  1198.     }
  1199. }
  1200. proc bigBraces {} {
  1201.     if {[wrapObject "\\left\\\{" "\\right\\\}•"]} then {
  1202.         message "formula delimited"
  1203.     } else {
  1204.         message "enter formula"
  1205.     }
  1206. }
  1207. proc bigAbsoluteValue {} {
  1208.     if {[wrapObject "\\left|" "\\right|•"]} then {
  1209.         message "formula delimited"
  1210.     } else {
  1211.         message "enter formula"
  1212.     }
  1213. }
  1214. proc otherBigDelims {} {
  1215.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" "braces" "angle brackets" "vertical bars" "double bars" "ceiling" "floor"} delimType
  1216.     if {$delimType != "cancel"} then {
  1217.         case $delimType in {
  1218.             "parentheses" {
  1219.                 set leftDelim "("
  1220.                 set rightDelim ")"
  1221.             }
  1222.             "brackets" {
  1223.                 set leftDelim "\["
  1224.                 set rightDelim "\]"
  1225.             }
  1226.             "braces" {
  1227.                 set leftDelim "\\\{"
  1228.                 set rightDelim "\\\}"
  1229.             }
  1230.             "{angle brackets}" {
  1231.                 set leftDelim "\\langle"
  1232.                 set rightDelim "\\rangle"
  1233.             }
  1234.             "{vertical bars}" {
  1235.                 set leftDelim "|"
  1236.                 set rightDelim "|"
  1237.             }
  1238.             "{double bars}" {
  1239.                 set leftDelim "\\|"
  1240.                 set rightDelim "\\|"
  1241.             }
  1242.             "ceiling" {
  1243.                 set leftDelim "\\lceil"
  1244.                 set rightDelim "\\rceil"
  1245.             }
  1246.             "floor" {
  1247.                 set leftDelim "\\lfloor"
  1248.                 set rightDelim "\\rfloor"
  1249.             }
  1250.             default {
  1251.                 alertnote "\"$delimType\" not recognized"
  1252.                 return
  1253.             }
  1254.         }
  1255.         if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1256.             message "formula delimited"
  1257.         } else {
  1258.             message "enter formula"
  1259.         }
  1260.     }
  1261. }
  1262.  
  1263. proc bigLeftBrace {} {
  1264.     if {[wrapObject "\\left\\\{" "\\right.•"]} then {
  1265.         message "formula delimited"
  1266.     } else {
  1267.         message "enter formula"
  1268.     }
  1269. }
  1270. proc otherMixedBigDelims {} {
  1271.     catch {prompt "Choose left delimiter:" "parenthesis" "" "parenthesis" "bracket" "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" "slash" "backslash" "none"} delimType
  1272.     if {$delimType != "cancel"} then {
  1273.         case $delimType in {
  1274.             "parenthesis" {set leftDelim "("}
  1275.             "bracket" {set leftDelim "\["}
  1276.             "brace" {set leftDelim "\\\{"}
  1277.             "{angle bracket}" {set leftDelim "\\langle"}
  1278.             "{vertical bar}" {set leftDelim "|"}
  1279.             "{double bar}" {set leftDelim "\\|"}
  1280.             "ceiling" {set leftDelim "\\lceil"}
  1281.             "floor" {set leftDelim "\\lfloor"}
  1282.             "slash" {set leftDelim "/"}
  1283.             "backslash" {set leftDelim "\\backslash"}
  1284.             "none" {set leftDelim "."}
  1285.             default {
  1286.                 alertnote "\"$delimType\" not recognized"
  1287.                 return
  1288.             }
  1289.         }
  1290.         catch {prompt "Choose right delimiter:" "parenthesis" "" "parenthesis" "bracket" "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" "slash" "backslash" "none"} delimType
  1291.         if {$delimType != "cancel"} then {
  1292.             case $delimType in {
  1293.                 "parenthesis" {set rightDelim ")"}
  1294.                 "bracket" {set rightDelim "\]"}
  1295.                 "brace" {set rightDelim "\\\}"}
  1296.                 "{angle bracket}" {set rightDelim "\\rangle"}
  1297.                 "{vertical bar}" {set rightDelim "|"}
  1298.                 "{double bar}" {set rightDelim "\\|"}
  1299.                 "ceiling" {set rightDelim "\\rceil"}
  1300.                 "floor" {set rightDelim "\\rfloor"}
  1301.                 "slash" {set rightDelim "/"}
  1302.                 "backslash" {set rightDelim "\\backslash"}
  1303.                 "none" {set rightDelim "."}
  1304.                 default {
  1305.                     alertnote "\"$delimType\" not recognized"
  1306.                     return
  1307.                 }
  1308.             }
  1309.             if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1310.                 message "formula delimited"
  1311.             } else {
  1312.                 message "enter formula"
  1313.             }
  1314.         }
  1315.     }
  1316. }
  1317.  
  1318. # Accents:
  1319. proc hat {} {
  1320.     if {[isSelection] > 1} then {
  1321.         beep
  1322.         alertnote "Warning: only a single character may be accented!"
  1323.     }
  1324.     if {[wrapObject "\\hat{" "}•"]} then {
  1325.         message "accent set"
  1326.     } else {
  1327.         message "enter one character"
  1328.     }
  1329. }
  1330. proc check {} {
  1331.     if {[isSelection] > 1} then {
  1332.         beep
  1333.         alertnote "Warning: only a single character may be accented!"
  1334.     }
  1335.     if {[wrapObject "\\check{" "}•"]} then {
  1336.         message "accent set"
  1337.     } else {
  1338.         message "enter one character"
  1339.     }
  1340. }
  1341. proc breve {} {
  1342.     if {[isSelection] > 1} then {
  1343.         beep
  1344.         alertnote "Warning: only a single character may be accented!"
  1345.     }
  1346.     if {[wrapObject "\\breve{" "}•"]} then {
  1347.         message "accent set"
  1348.     } else {
  1349.         message "enter one character"
  1350.     }
  1351. }
  1352. proc acuteAccent {} {
  1353.     if {[isSelection] > 1} then {
  1354.         beep
  1355.         alertnote "Warning: only a single character may be accented!"
  1356.     }
  1357.     if {[wrapObject "\\acute{" "}•"]} then {
  1358.         message "accent set"
  1359.     } else {
  1360.         message "enter one character"
  1361.     }
  1362. }
  1363. proc graveAccent {} {
  1364.     if {[isSelection] > 1} then {
  1365.         beep
  1366.         alertnote "Warning: only a single character may be accented!"
  1367.     }
  1368.     if {[wrapObject "\\grave{" "}•"]} then {
  1369.         message "accent set"
  1370.     } else {
  1371.         message "enter one character"
  1372.     }
  1373. }
  1374. proc tilde {} {
  1375.     if {[isSelection] > 1} then {
  1376.         beep
  1377.         alertnote "Warning: only a single character may be accented!"
  1378.     }
  1379.     if {[wrapObject "\\tilde{" "}•"]} then {
  1380.         message "accent set"
  1381.     } else {
  1382.         message "enter one character"
  1383.     }
  1384. }
  1385. proc bar {} {
  1386.     if {[isSelection] > 1} then {
  1387.         beep
  1388.         alertnote "Warning: only a single character may be accented!"
  1389.     }
  1390.     if {[wrapObject "\\bar{" "}•"]} then {
  1391.         message "accent set"
  1392.     } else {
  1393.         message "enter one character"
  1394.     }
  1395. }
  1396. proc vector {} {
  1397.     if {[isSelection] > 1} then {
  1398.         beep
  1399.         alertnote "Warning: only a single character may be accented!"
  1400.     }
  1401.     if {[wrapObject "\\vec{" "}•"]} then {
  1402.         message "accent set"
  1403.     } else {
  1404.         message "enter one character"
  1405.     }
  1406. }
  1407. proc dot {} {
  1408.     if {[isSelection] > 1} then {
  1409.         beep
  1410.         alertnote "Warning: only a single character may be accented!"
  1411.     }
  1412.     if {[wrapObject "\\dot{" "}•"]} then {
  1413.         message "accent set"
  1414.     } else {
  1415.         message "enter one character"
  1416.     }
  1417. }
  1418. proc dblDot {} {
  1419.     if {[isSelection] > 1} then {
  1420.         beep
  1421.         alertnote "Warning: only a single character may be accented!"
  1422.     }
  1423.     if {[wrapObject "\\ddot{" "}•"]} then {
  1424.         message "accent set"
  1425.     } else {
  1426.         message "enter one character"
  1427.     }
  1428. }
  1429.  
  1430. proc wideHat {} {
  1431.     if {[isSelection] > 3} then {
  1432.         beep
  1433.         alertnote "Warning: only a few characters may be accented!"
  1434.     }
  1435.     if {[wrapObject "\\widehat{" "}•"]} then {
  1436.         message "accent set"
  1437.     } else {
  1438.         message "enter a few characters"
  1439.     }
  1440. }
  1441. proc wideTilde {} {
  1442.     if {[isSelection] > 3} then {
  1443.         beep
  1444.         alertnote "Warning: only a few characters may be accented!"
  1445.     }
  1446.     if {[wrapObject "\\widetilde{" "}•"]} then {
  1447.         message "accent set"
  1448.     } else {
  1449.         message "enter a few characters"
  1450.     }
  1451. }
  1452.  
  1453. proc dotlessI {} {insertObject "\\imath"}
  1454. proc dotlessJ {} {insertObject "\\jmath"}
  1455.  
  1456. # Grouping:
  1457. proc underline {} {
  1458.     if {[wrapObject "\\underline{" "}•"]} then {
  1459.         message "selection underlined"
  1460.     } else {
  1461.         message "enter text"
  1462.     }
  1463. }
  1464. proc overline {} {
  1465.     if {[wrapObject "\\overline{" "}•"]} then {
  1466.         message "selection overlined"
  1467.     } else {
  1468.         message "enter text"
  1469.     }
  1470. }
  1471. proc underbrace {} {
  1472.     if {[wrapObject "\\underbrace{" "}•"]} then {
  1473.         message "selection underbraced"
  1474.     } else {
  1475.         message "enter text"
  1476.     }
  1477. }
  1478. proc overbrace {} {
  1479.     if {[wrapObject "\\overbrace{" "}•"]} then {
  1480.         message "selection overbraced"
  1481.     } else {
  1482.         message "enter text"
  1483.     }
  1484. }
  1485. proc stack {} {
  1486.     set currentPos [getPos]
  1487.     if {[insertObject "\\stackrel{•}{•}•"]} then {
  1488.         goto $currentPos
  1489.         nextTabStop
  1490.         message "1st arg scriptstyle"
  1491.     }
  1492. }
  1493.  
  1494. # Spacing:
  1495. proc thin {} {insertObject "\\,"}
  1496. proc negThin {} {insertObject "\\!"}
  1497. proc medium {} {insertObject "\\:"}
  1498. proc thick {} {insertObject "\\;"}
  1499. proc quad {} {insertObject "\\quad"}
  1500. proc dblQuad {} {insertObject "\\qquad"}
  1501.  
  1502. # Math Style:
  1503. proc mathItalic {} {
  1504.     if {[wrapObject "{\\mit " "}•"]} then {
  1505.         message "math italics set"
  1506.     } else {
  1507.         message "enter italicized text"
  1508.     }
  1509. }
  1510. proc calligraphic {} {
  1511.     # Check for upper-case arguments only:
  1512.     if {[wrapObject "{\\cal " "}•"]} then {
  1513.         message "calligraphics set"
  1514.     } else {
  1515.         message "enter text"
  1516.     }
  1517. }
  1518. proc fraktur {} {
  1519.     alertnote "Not yet implemented."
  1520. }
  1521. proc script {} {
  1522.     alertnote "Not yet implemented."
  1523. }
  1524. proc blackboardBold {} {
  1525.     alertnote "Not yet implemented."
  1526. }
  1527. proc displayStyle {} {
  1528.     if {[wrapObject "{\\displaystyle " "}•"]} then {
  1529.         message "displaystyle set"
  1530.     } else {
  1531.         message "enter displaystyle text"
  1532.     }
  1533. }
  1534. proc textStyle {} {
  1535.     if {[wrapObject "{\\textstyle " "}•"]} then {
  1536.         message "textstyle set"
  1537.     } else {
  1538.         message "enter textstyle text"
  1539.     }
  1540. }
  1541. proc scriptStyle {} {
  1542.     if {[wrapObject "{\\scriptstyle " "}•"]} then {
  1543.         message "scriptstyle set"
  1544.     } else {
  1545.         message "enter scriptstyle text"
  1546.     }
  1547. }
  1548. proc scriptscriptStyle {} {
  1549.     if {[wrapObject "{\\scriptscriptstyle " "}•"]} then {
  1550.         message "scriptscriptstyle set"
  1551.     } else {
  1552.         message "enter scriptscriptstyle text"
  1553.     }
  1554. }
  1555.  
  1556.  
  1557. #############################################################################
  1558. #
  1559. # LaTeX Menu Definition.
  1560. #
  1561. #############################################################################
  1562.  
  1563. proc interpretMenuItem {menu item} {
  1564.     case $item in {
  1565.         "list" {set func "myList"}
  1566.         "array" {set func "myArray"}
  1567.         "eqnarray\*" {set func "eqnarrayStar"}
  1568.         default {set func $item}
  1569.     }
  1570.     eval $func
  1571. }
  1572.  
  1573. menu -n LaTeX {
  1574.     {menu -n Documents -p interpretMenuItem {
  1575.         "letter"
  1576.         "article"
  1577.         "report"
  1578.         "book"
  1579.         "(-"
  1580.         "custom…"}
  1581.     }
  1582.     
  1583.     {menu -n Sectioning -p interpretMenuItem {
  1584.         "part"
  1585.         "chapter"
  1586.         "section"
  1587.         "subsection"
  1588.         "subsubsection"
  1589.         "paragraph"
  1590.         "subparagraph"}
  1591.     }
  1592.     
  1593.     {menu -n (Definitions -p interpretMenuItem {
  1594.         "list…"
  1595.         "(-"
  1596.         "newcommand…"
  1597.         "newenvironment…"
  1598.         "newtheorem…"
  1599.         "(-"
  1600.         "renewcommand…"
  1601.         "renewenvironment…"}
  1602.     }
  1603.     
  1604.     "(-"
  1605.     
  1606.     {menu -n TextStyle -p interpretMenuItem {
  1607.         "roman"
  1608.         "bold"
  1609.         "italic"
  1610.         "emphatic"
  1611.         "slanted"
  1612.         "sansSerif"
  1613.         "smallCaps"
  1614.         "typewriter"}
  1615.     }
  1616.     
  1617.     {menu -n TextSize -p interpretMenuItem {
  1618.         "tiny"
  1619.         "smallest"
  1620.         "smaller"
  1621.         "small"
  1622.         "normal"
  1623.         "large"
  1624.         "larger"
  1625.         "largest"
  1626.         "huge"
  1627.         "gigantic"}
  1628.     }
  1629.     
  1630.     {menu -n (International -p interpretMenuItem {
  1631.         }
  1632.     }
  1633.     
  1634.     {menu -n Environments -p interpretMenuItem {
  1635.         "enumerate…"
  1636.         "itemize…"
  1637.         "description…"
  1638.         "(-"
  1639.         "tabular…"
  1640.         "(tabbing"
  1641.         "(-"
  1642.         "figure"
  1643.         "table"
  1644.         "slide"
  1645.         "(-"
  1646.         "verbatim"
  1647.         "quote"
  1648.         "quotation"
  1649.         "verse"
  1650.         "(-"
  1651.         "(index…"
  1652.         "bibliography…"
  1653.         "(-"
  1654.         "general…"}
  1655.     }
  1656.     
  1657.     {menu -n Boxes -p interpretMenuItem {
  1658.         "mbox"
  1659.         "(fbox"
  1660.         "(parbox"}
  1661.     }
  1662.     
  1663.     {menu -n Miscellaneous -p interpretMenuItem {
  1664.         "ellipsis"
  1665.         "sectionMark"
  1666.         "paragraphMark"
  1667.         "dagger"
  1668.         "dblDagger"
  1669.         "en-dash"
  1670.         "em-dash"
  1671.         "texLogo"
  1672.         "latexLogo"
  1673.         "copyright"
  1674.         "pounds"
  1675.         "date"
  1676.         "(-"
  1677.         "quotes"
  1678.         "dblQuotes"
  1679.         "(-"
  1680.         "note"
  1681.         "footnote"
  1682.         "(-"
  1683.         "label"
  1684.         "crossRef"
  1685.         "pageRef"
  1686.         "citation"
  1687.         "(-"
  1688.         "item"
  1689.         "bibitem"
  1690.         }
  1691.     }
  1692.     
  1693.     "(-"
  1694.     
  1695.     {menu -n mathModes -p interpretMenuItem {
  1696.         "texMath"
  1697.         "texDisplaymath"
  1698.         "(-"
  1699.         "latexMath"
  1700.         "latexDisplaymath"}
  1701.     }
  1702.     
  1703.     {menu -n mathEnvironments -p interpretMenuItem {
  1704.         "math"
  1705.         "displaymath"
  1706.         "equation"
  1707.         "(-"
  1708.         "array…"
  1709.         "eqnarray…"
  1710.         "eqnarray*…"
  1711.         "(-"
  1712.         "general…"}
  1713.     }
  1714.     
  1715.     {menu -n Formulas -p interpretMenuItem {
  1716.         "subscript"
  1717.         "superscript"
  1718.         "fraction"
  1719.         "squareRoot"
  1720.         "nthRoot"
  1721.         "(-"
  1722.         "oneParameter…"
  1723.         "twoParameters…"
  1724.         }
  1725.     }
  1726.     
  1727.     {menu -n Greek -p interpretMenuItem {
  1728.         "alpha"
  1729.         "beta"
  1730.         "gamma"
  1731.         "delta"
  1732.         "epsilon"
  1733.         "zeta"
  1734.         "eta"
  1735.         "theta"
  1736.         "iota"
  1737.         "kappa"
  1738.         "lambda"
  1739.         "mu"
  1740.         "nu"
  1741.         "xi"
  1742.         "pi"
  1743.         "rho"
  1744.         "sigma"
  1745.         "tau"
  1746.         "upsilon"
  1747.         "phi"
  1748.         "chi"
  1749.         "psi"
  1750.         "omega"
  1751.         }
  1752.     }
  1753.     {menu -n Greek2 -p interpretMenuItem {
  1754.         "capGamma"
  1755.         "capDelta"
  1756.         "capTheta"
  1757.         "capLambda"
  1758.         "capXi"
  1759.         "capPi"
  1760.         "capSigma"
  1761.         "capUpsilon"
  1762.         "capPhi"
  1763.         "capPsi"
  1764.         "capOmega"
  1765.         "(-"
  1766.         "varEpsilon"
  1767.         "varTheta"
  1768.         "varPi"
  1769.         "varRho"
  1770.         "varSigma"
  1771.         "varPhi"
  1772.         }
  1773.     }
  1774.         
  1775.     {menu -n BinaryOperators -p interpretMenuItem {
  1776.         "plusOrMinus"
  1777.         "minusOrPlus"
  1778.         "multiply"
  1779.         "divide"
  1780.         "asterisk"
  1781.         "star"
  1782.         "centerDot"
  1783.         "bullet"
  1784.         "circle"
  1785.         "bigCircle"
  1786.         "intersection"
  1787.         "union"
  1788.         "logicalAnd"
  1789.         "logicalOr"
  1790.         "setMinus"
  1791.         }
  1792.     }
  1793.     
  1794.     {menu -n Relations -p interpretMenuItem {
  1795.         "notEqual"
  1796.         "lessOrEqual"
  1797.         "greaterOrEqual"
  1798.         "subset"
  1799.         "superset"
  1800.         "subsetOrEqual"
  1801.         "supersetOrEqual"
  1802.         "elementOf"
  1803.         "equivalent"
  1804.         "similar"
  1805.         "similarEqual"
  1806.         "dotEqual"
  1807.         "approximate"
  1808.         "congruent"
  1809.         }
  1810.     }
  1811.     
  1812.     {menu -n LargeOperators -p interpretMenuItem {
  1813.         "sum"
  1814.         "product"
  1815.         "integral"
  1816.         "bigUnion"
  1817.         "bigIntersection"
  1818.         "bigAnd"
  1819.         "bigOr"
  1820.         }
  1821.     }
  1822.     
  1823.     {menu -n Arrows -p interpretMenuItem {
  1824.         "mapsTo"
  1825.         "leftArrow"
  1826.         "rightArrow"
  1827.         "left-rightArrow"
  1828.         "dblLeftArrow"
  1829.         "dblRightArrow"
  1830.         "dblLeft-rightArrow"
  1831.         }
  1832.     }
  1833.     
  1834.     {menu -n Dots -p interpretMenuItem {
  1835.         "centerDot"
  1836.         "bullet"
  1837.         "(-"
  1838.         "ellipsis"
  1839.         "centerDots"
  1840.         "verticalDots"
  1841.         "diagonalDots"
  1842.         }
  1843.     }
  1844.     
  1845.     {menu -n Symbols -p interpretMenuItem {
  1846.         "aleph"
  1847.         "emptySet"
  1848.         "negation"
  1849.         "forAll"
  1850.         "exists"
  1851.         "scriptL"
  1852.         "nabla"
  1853.         "partial"
  1854.         "infinity"
  1855.         "backslash"
  1856.         "angle"
  1857.         "box"
  1858.         "diamond"
  1859.         "triangle"
  1860.         }
  1861.     }
  1862.         
  1863.     {menu -n (Functions -p interpretMenuItem {
  1864.         }
  1865.     }
  1866.  
  1867.     {menu -n Delimiters -p interpretMenuItem {
  1868.         "parentheses"
  1869.         "brackets"
  1870.         "braces"
  1871.         "absoluteValue"
  1872.         "otherDelims…"
  1873.         "(-"
  1874.         "half-openInterval"
  1875.         "half-closedInterval"
  1876.         "(-"
  1877.         "bigParentheses"
  1878.         "bigBrackets"
  1879.         "bigBraces"
  1880.         "bigAbsoluteValue"
  1881.         "otherBigDelims…"
  1882.         "(-"
  1883.         "bigLeftBrace"
  1884.         "otherMixedBigDelims…"
  1885.         }
  1886.     }
  1887.         
  1888.     {menu -n mathAccents -p interpretMenuItem {
  1889.         "hat"
  1890.         "check"
  1891.         "breve"
  1892.         "acuteAccent"
  1893.         "graveAccent"
  1894.         "tilde"
  1895.         "bar"
  1896.         "vector"
  1897.         "dot"
  1898.         "dblDot"
  1899.         "(-"
  1900.         "wideHat"
  1901.         "wideTilde"
  1902.         "(-"
  1903.         "dotlessI"
  1904.         "dotlessJ"
  1905.         }
  1906.     }
  1907.     
  1908.     {menu -n Grouping -p interpretMenuItem {
  1909.         "underline"
  1910.         "overline"
  1911.         "underbrace"
  1912.         "overbrace"
  1913.         "(-"
  1914.         "stack"
  1915.         }
  1916.     }
  1917.     
  1918.     {menu -n Spacing -p interpretMenuItem {
  1919.         "thin"
  1920.         "negThin"
  1921.         "medium"
  1922.         "thick"
  1923.         "(-"
  1924.         "quad"
  1925.         "dblQuad"
  1926.         }
  1927.     }
  1928.     
  1929.     {menu -n MathStyle -p interpretMenuItem {
  1930.         "mathItalic"
  1931.         "calligraphic"
  1932.         "(-"
  1933.         "(fraktur"
  1934.         "(script"
  1935.         "(blackboardBold"
  1936.         "(-"
  1937.         "displayStyle"
  1938.         "textStyle"
  1939.         "scriptStyle"
  1940.         "scriptscriptStyle"
  1941.         }
  1942.     }
  1943. }
  1944.  
  1945.  
  1946. #############################################################################
  1947. #
  1948. # Special Key Bindings.
  1949. #
  1950. # abbreviations:  <o> = option, <z> = control, <s> = shift, <c> = command
  1951. #
  1952. #############################################################################
  1953.  
  1954. if {$optionIsMeta == "0"} then {
  1955.  
  1956.     #  use option for macros, escape for meta
  1957.  
  1958.     bind    'a'    <o>    alpha    "Tex"
  1959.     bind    'a'    <os>    angle    "Tex"
  1960.     bind    'a'    <oz>    forAll    "Tex"
  1961.     bind    'a'    <co>    acuteAccent    "Tex"
  1962.     
  1963.     bind    'b'    <o>    beta    "Tex"
  1964.     bind    'b'    <oz>    box    "Tex"
  1965.     bind    'b'    <co>    bar    "Tex"
  1966.     bind    'b'    <cs>    bold    "Tex"
  1967.     
  1968.     bind    'c'    <o>    chi    "Tex"
  1969.     bind    'c'    <co>    check    "Tex"
  1970.     bind    'c'    <cs>    citation    "Tex"
  1971.     bind    'c'    <cso>    calligraphic    "Tex"
  1972.     
  1973.     bind    'd'    <o>    delta    "Tex"
  1974.     bind    'd'    <os>    capDelta    "Tex"
  1975.     bind    'd'    <oz>    diamond    "Tex"
  1976.     bind    'd'    <co>    dot    "Tex"
  1977.     bind    'd'    <cso>    dblDot    "Tex"
  1978.     
  1979.     bind    'e'    <o>    epsilon    "Tex"
  1980.     bind    'e'    <os>    exists    "Tex"
  1981.     bind    'e'    <oz>    varEpsilon    "Tex"
  1982.     bind    'e'    <cs>    emphatic    "Tex"
  1983.     
  1984.     bind    'f'    <o>    phi    "Tex"
  1985.     bind    'f'    <os>    capPhi    "Tex"
  1986.     bind    'f'    <oz>    varPhi    "Tex"
  1987.     bind    'f'    <co>    fraction    "Tex"
  1988.     bind    'f'    <cs>    footnote    "Tex"
  1989.     
  1990.     bind    'g'    <o>    gamma    "Tex"
  1991.     bind    'g'    <os>    capGamma    "Tex"
  1992.     bind    'g'    <oz>    copyright    "Tex"
  1993.     bind    'g'    <co>    graveAccent    "Tex"
  1994.     
  1995.     bind    'h'    <o>    eta    "Tex"
  1996.     bind    'h'    <co>    hat    "Tex"
  1997.     bind    'h'    <cs>    smallCaps    "Tex"
  1998.     bind    'h'    <cso>    wideHat    "Tex"
  1999.     
  2000.     bind    'i'    <o>    iota    "Tex"
  2001.     bind    'i'    <oz>    dotlessI    "Tex"
  2002.     bind    'i'    <co>    integral    "Tex"
  2003.     bind    'i'    <cs>    italic    "Tex"
  2004.     bind    'i'    <cso>    mathItalic    "Tex"
  2005.     
  2006.     bind    'j'    <o>    partial    "Tex"
  2007.     bind    'j'    <oz>    dotlessJ    "Tex"
  2008.     
  2009.     bind    'k'    <o>    kappa    "Tex"
  2010.     
  2011.     bind    'l'    <o>    lambda    "Tex"
  2012.     bind    'l'    <os>    capLambda    "Tex"
  2013.     bind    'l'    <oz>    scriptL    "Tex"
  2014.     bind    'l'    <cs>    label    "Tex"
  2015.     
  2016.     bind    'm'    <o>    mu    "Tex"
  2017.     bind    'm'    <oz>    mapsTo    "Tex"
  2018.     bind    'm'    <co>    mbox    "Tex"
  2019.     bind    'm'    <cs>    mbox    "Tex"
  2020.     
  2021.     bind    'n'    <o>    nu    "Tex"
  2022.     bind    'n'    <os>    aleph    "Tex"
  2023.     bind    'n'    <oz>    intersection    "Tex"
  2024.     bind    'n'    <co>    nthRoot    "Tex"
  2025.     bind    'n'    <cs>    note    "Tex"
  2026.     
  2027.     bind    'o'    <o>    circle    "Tex"
  2028.     bind    'o'    <os>    bigCircle    "Tex"
  2029.     bind    'o'    <co>    overline    "Tex"
  2030.     bind    'o'    <cso>    overbrace    "Tex"
  2031.     
  2032.     bind    'p'    <o>    pi    "Tex"
  2033.     bind    'p'    <os>    capPi    "Tex"
  2034.     bind    'p'    <oz>    varPi    "Tex"
  2035.     bind    'p'    <co>    product    "Tex"
  2036.     bind    'p'    <cs>    pageRef    "Tex"
  2037.     
  2038.     bind    'q'    <o>    theta    "Tex"
  2039.     bind    'q'    <os>    capTheta    "Tex"
  2040.     bind    'q'    <oz>    varTheta    "Tex"
  2041.     
  2042.     bind    'r'    <o>    rho    "Tex"
  2043.     bind    'r'    <oz>    varRho    "Tex"
  2044.     bind    'r'    <co>    squareRoot    "Tex"
  2045.     bind    'r'    <cs>    roman    "Tex"
  2046.     
  2047.     bind    's'    <o>    sigma    "Tex"
  2048.     bind    's'    <os>    capSigma    "Tex"
  2049.     bind    's'    <oz>    varSigma    "Tex"
  2050.     bind    's'    <co>    sum    "Tex"
  2051.     bind    's'    <cs>    slanted    "Tex"
  2052.     
  2053.     bind    't'    <o>    tau    "Tex"
  2054.     bind    't'    <os>    dagger    "Tex"
  2055.     bind    't'    <oz>    triangle    "Tex"
  2056.     bind    't'    <co>    tilde    "Tex"
  2057.     bind    't'    <cs>    typewriter    "Tex"
  2058.     bind    't'    <cso>    wideTilde    "Tex"
  2059.     
  2060.     bind    'u'    <o>    upsilon    "Tex"
  2061.     bind    'u'    <os>    capUpsilon    "Tex"
  2062.     bind    'u'    <oz>    union    "Tex"
  2063.     bind    'u'    <co>    underline    "Tex"
  2064.     bind    'u'    <cso>    underbrace    "Tex"
  2065.     
  2066.     bind    'v'    <o>    nabla    "Tex"
  2067.     bind    'v'    <oz>    logicalOr    "Tex"
  2068.     bind    'v'    <co>    vector    "Tex"
  2069.     
  2070.     bind    'w'    <o>    omega    "Tex"
  2071.     bind    'w'    <os>    capOmega    "Tex"
  2072.     bind    'w'    <oz>    logicalAnd    "Tex"
  2073.     bind    'w'    <cs>    sansSerif    "Tex"
  2074.     
  2075.     bind    'x'    <o>    xi    "Tex"
  2076.     bind    'x'    <os>    capXi    "Tex"
  2077.     bind    'x'    <oz>    multiply    "Tex"
  2078.     bind    'x'    <cs>    crossRef    "Tex"
  2079.     
  2080.     bind    'y'    <o>    psi    "Tex"
  2081.     bind    'y'    <os>    capPsi    "Tex"
  2082.     
  2083.     bind    'z'    <o>    zeta    "Tex"
  2084.     
  2085.     bind    '\ '    <o>    thin    "Tex"
  2086.     bind    '\ '    <os>    negThin    "Tex"
  2087.     bind    '\ '    <oz>    medium    "Tex"
  2088.     bind    '\ '    <co>    thick    "Tex"
  2089.     bind    '\ '    <cs>    quad    "Tex"
  2090.     bind    '\ '    <cso>    dblQuad    "Tex"
  2091.     
  2092.     bind    ','    <o>    lessOrEqual    "Tex"
  2093.     bind    ','    <os>    subset    "Tex"
  2094.     bind    ','    <oz>    subsetOrEqual    "Tex"
  2095.     bind    ','    <co>    subscript    "Tex"
  2096.     
  2097.     bind    '.'    <o>    greaterOrEqual    "Tex"
  2098.     bind    '.'    <os>    superset    "Tex"
  2099.     bind    '.'    <oz>    supersetOrEqual    "Tex"
  2100.     bind    '.'    <co>    superscript    "Tex"
  2101.     
  2102.     bind    '/'    <o>    divide    "Tex"
  2103.     bind    '/'    <co>    fraction    "Tex"
  2104.     
  2105.     bind    '\;'    <o>    ellipsis    "Tex"
  2106.     bind    '\;'    <os>    centerDots    "Tex"
  2107.     bind    '\;'    <oz>    verticalDots    "Tex"
  2108.     bind    '\;'    <co>    diagonalDots    "Tex"
  2109.     
  2110.     # apostrophe:
  2111.     bind    0x27    <co>    acuteAccent    "Tex"
  2112.     bind    0x27    <cs>    quotes    "Tex"
  2113.     bind    0x27    <cso>    dblQuotes    "Tex"
  2114.  
  2115.     bind    '\['    <o>    brackets    "Tex"
  2116.     bind    '\['    <os>    braces    "Tex"
  2117.     bind    '\['    <co>    bigBrackets    "Tex"
  2118.     bind    '\['    <cso>    bigBraces    "Tex"
  2119.  
  2120.     bind    '\]'    <o>    displayStyle    "Tex"
  2121.     bind    '\]'    <os>    textStyle    "Tex"
  2122.     bind    '\]'    <oz>    scriptStyle    "Tex"
  2123.     bind    '\]'    <co>    scriptscriptStyle    "Tex"
  2124.     bind    '\]'    <cso>    bigLeftBrace    "Tex"
  2125.     
  2126.     bind    '\'    <o>    backslash    "Tex"
  2127.     bind    '\'    <os>    absoluteValue    "Tex"
  2128.     bind    '\'    <oz>    setMinus    "Tex"
  2129.     bind    '\'    <co>    bigAbsoluteValue    "Tex"
  2130.     bind    '\'    <cs>    "oneParameter"    "Tex"
  2131.     bind    '\'    <cso>    "twoParameters"    "Tex"
  2132.     
  2133.     bind    '`'    <co>    graveAccent    "Tex"
  2134.     bind    '`'    <cso>    tilde    "Tex"
  2135.         
  2136.     # Change to latexMath and latexDisplaymath, if desired:
  2137.     bind    '4'    <co>    texMath    "Tex"
  2138.     bind    '4'    <cso>    texDisplaymath    "Tex"
  2139.     
  2140.     bind    '5'    <o>    infinity    "Tex"
  2141.     
  2142.     bind    '6'    <o>    sectionMark    "Tex"
  2143.     bind    '6'    <co>    superscript    "Tex"
  2144.     
  2145.     bind    '7'    <o>    paragraphMark    "Tex"
  2146.     
  2147.     bind    '8'    <o>    bullet    "Tex"
  2148.     bind    '8'    <os>    asterisk    "Tex"
  2149.     bind    '8'    <oz>    centerDot    "Tex"
  2150.     
  2151.     bind    '9'    <os>    parentheses    "Tex"
  2152.     bind    '9'    <co>    bigParentheses    "Tex"
  2153.     
  2154.     bind    '0'    <oz>    emptySet    "Tex"
  2155.     
  2156.     bind    '-'    <o>    similar    "Tex"
  2157.     bind    '-'    <os>    minusOrPlus    "Tex"
  2158.     bind    '-'    <oz>    negation    "Tex"
  2159.     bind    '-'    <co>    subscript    "Tex"
  2160.     
  2161.     bind    '='    <o>    notEqual    "Tex"
  2162.     bind    '='    <os>    plusOrMinus    "Tex"
  2163.     bind    '='    <oz>    approximate    "Tex"
  2164.     bind    '='    <co>    bar    "Tex"
  2165.     
  2166.     bind    F5    <o>    math    "Tex"
  2167.     bind    F5    <os>    displaymath    "Tex"
  2168.     bind    F5    <oz>    equation    "Tex"
  2169.     
  2170.     bind    F6    <o>    "myArray"    "Tex"
  2171.     bind    F6    <os>    "eqnarray"    "Tex"
  2172.     bind    F6    <oz>    "eqnarrayStar"    "Tex"
  2173.     
  2174.     bind    F7    <o>    "enumerate"    "Tex"
  2175.     bind    F7    <os>    "itemize"    "Tex"
  2176.     bind    F7    <oz>    "description"    "Tex"
  2177.     
  2178.     bind    F8    <o>    "tabular"    "Tex"
  2179.     bind    F8    <os>    tabbing    "Tex"
  2180.     
  2181.     bind    F9    <o>    figure    "Tex"
  2182.     bind    F9    <os>    table    "Tex"
  2183.     bind    F9    <oz>    slide    "Tex"
  2184.     
  2185.     bind    F10    <o>    verbatim    "Tex"
  2186.     bind    F10    <os>    quote    "Tex"
  2187.     bind    F10    <oz>    quotation    "Tex"
  2188.     bind    F10    <co>    verse    "Tex"
  2189.     
  2190.     bind    F11    <o>    "index"    "Tex"
  2191.     bind    F11    <os>    "bibliography"    "Tex"
  2192.     
  2193.     bind    F12    <o>    "general"    "Tex"
  2194.     
  2195.     # tab:
  2196.     bind    0x30    nextTabStop    "Tex"
  2197.     bind    0x30    <s>     previousTabStop    "Tex"
  2198.     
  2199. } else {
  2200.     
  2201.     #    bind    macros    to    option-control,    use    option    as    meta
  2202.     
  2203.     bind    'a'    <zo>    alpha    "Tex"
  2204.     bind    'a'    <zos>    angle    "Tex"
  2205.     # bind    'a'    <oz>    forAll    "Tex"
  2206.     bind    'a'    <zco>    acuteAccent    "Tex"
  2207.     
  2208.     bind    'b'    <zo>    beta    "Tex"
  2209.     # bind    'b'    <oz>    box    "Tex"
  2210.     bind    'b'    <zco>    bar    "Tex"
  2211.     bind    'b'    <zcs>    bold    "Tex"
  2212.     
  2213.     bind    'c'    <zo>    chi    "Tex"
  2214.     bind    'c'    <zco>    check    "Tex"
  2215.     bind    'c'    <zcs>    citation    "Tex"
  2216.     bind    'c'    <zcso>    calligraphic    "Tex"
  2217.     
  2218.     bind    'd'    <zo>    delta    "Tex"
  2219.     bind    'd'    <zos>    capDelta    "Tex"
  2220.     # bind    'd'    <oz>    diamond    "Tex"
  2221.     bind    'd'    <zco>    dot    "Tex"
  2222.     bind    'd'    <zcso>    dblDot    "Tex"
  2223.     
  2224.     bind    'e'    <zo>    epsilon    "Tex"
  2225.     bind    'e'    <zos>    exists    "Tex"
  2226.     # bind    'e'    <oz>    varEpsilon    "Tex"
  2227.     bind    'e'    <zcs>    emphatic    "Tex"
  2228.     
  2229.     bind    'f'    <zo>    phi    "Tex"
  2230.     bind    'f'    <zos>    capPhi    "Tex"
  2231.     # bind    'f'    <oz>    varPhi    "Tex"
  2232.     bind    'f'    <zco>    fraction    "Tex"
  2233.     bind    'f'    <zcs>    footnote    "Tex"
  2234.     
  2235.     bind    'g'    <zo>    gamma    "Tex"
  2236.     bind    'g'    <zos>    capGamma    "Tex"
  2237.     # bind    'g'    <oz>    copyright    "Tex"
  2238.     bind    'g'    <zco>    graveAccent    "Tex"
  2239.     
  2240.     bind    'h'    <zo>    eta    "Tex"
  2241.     bind    'h'    <zco>    hat    "Tex"
  2242.     bind    'h'    <zcs>    smallCaps    "Tex"
  2243.     bind    'h'    <zcso>    wideHat    "Tex"
  2244.     
  2245.     bind    'i'    <zo>    iota    "Tex"
  2246.     # bind    'i'    <oz>    dotlessI    "Tex"
  2247.     bind    'i'    <zco>    integral    "Tex"
  2248.     bind    'i'    <zcs>    italic    "Tex"
  2249.     bind    'i'    <zcso>    mathItalic    "Tex"
  2250.     
  2251.     bind    'j'    <zo>    partial    "Tex"
  2252.     # bind    'j'    <oz>    dotlessJ    "Tex"
  2253.     
  2254.     bind    'k'    <zo>    kappa    "Tex"
  2255.     
  2256.     bind    'l'    <zo>    lambda    "Tex"
  2257.     bind    'l'    <zos>    capLambda    "Tex"
  2258.     # bind    'l'    <oz>    scriptL    "Tex"
  2259.     bind    'l'    <zcs>    label    "Tex"
  2260.     
  2261.     bind    'm'    <zo>    mu    "Tex"
  2262.     # bind    'm'    <oz>    mapsTo    "Tex"
  2263.     bind    'm'    <zco>    mbox    "Tex"
  2264.     bind    'm'    <zcs>    mbox    "Tex"
  2265.     
  2266.     bind    'n'    <zo>    nu    "Tex"
  2267.     bind    'n'    <zos>    aleph    "Tex"
  2268.     # bind    'n'    <oz>    intersection    "Tex"
  2269.     bind    'n'    <zco>    nthRoot    "Tex"
  2270.     bind    'n'    <zcs>    note    "Tex"
  2271.     
  2272.     bind    'o'    <zo>    circle    "Tex"
  2273.     bind    'o'    <zos>    bigCircle    "Tex"
  2274.     bind    'o'    <zco>    overline    "Tex"
  2275.     bind    'o'    <zcso>    overbrace    "Tex"
  2276.     
  2277.     bind    'p'    <zo>    pi    "Tex"
  2278.     bind    'p'    <zos>    capPi    "Tex"
  2279.     # bind    'p'    <oz>    varPi    "Tex"
  2280.     bind    'p'    <zco>    product    "Tex"
  2281.     bind    'p'    <zcs>    pageRef    "Tex"
  2282.     
  2283.     bind    'q'    <zo>    theta    "Tex"
  2284.     bind    'q'    <zos>    capTheta    "Tex"
  2285.     # bind    'q'    <oz>    varTheta    "Tex"
  2286.     
  2287.     bind    'r'    <zo>    rho    "Tex"
  2288.     # bind    'r'    <oz>    varRho    "Tex"
  2289.     bind    'r'    <zco>    squareRoot    "Tex"
  2290.     bind    'r'    <zcs>    roman    "Tex"
  2291.     
  2292.     bind    's'    <zo>    sigma    "Tex"
  2293.     bind    's'    <zos>    capSigma    "Tex"
  2294.     # bind    's'    <oz>    varSigma    "Tex"
  2295.     bind    's'    <zco>    sum    "Tex"
  2296.     bind    's'    <zcs>    slanted    "Tex"
  2297.     
  2298.     bind    't'    <zo>    tau    "Tex"
  2299.     bind    't'    <zos>    dagger    "Tex"
  2300.     # bind    't'    <oz>    triangle    "Tex"
  2301.     bind    't'    <zco>    tilde    "Tex"
  2302.     bind    't'    <zcs>    typewriter    "Tex"
  2303.     bind    't'    <zcso>    wideTilde    "Tex"
  2304.     
  2305.     bind    'u'    <zo>    upsilon    "Tex"
  2306.     bind    'u'    <zos>    capUpsilon    "Tex"
  2307.     # bind    'u'    <oz>    union    "Tex"
  2308.     bind    'u'    <zco>    underline    "Tex"
  2309.     bind    'u'    <zcso>    underbrace    "Tex"
  2310.     
  2311.     bind    'v'    <zo>    nabla    "Tex"
  2312.     # bind    'v'    <oz>    logicalOr    "Tex"
  2313.     bind    'v'    <zco>    vector    "Tex"
  2314.     
  2315.     bind    'w'    <zo>    omega    "Tex"
  2316.     bind    'w'    <zos>    capOmega    "Tex"
  2317.     # bind    'w'    <oz>    logicalAnd    "Tex"
  2318.     bind    'w'    <zcs>    sansSerif    "Tex"
  2319.     
  2320.     bind    'x'    <zo>    xi    "Tex"
  2321.     bind    'x'    <zos>    capXi    "Tex"
  2322.     # bind    'x'    <oz>    multiply    "Tex"
  2323.     bind    'x'    <zcs>    crossRef    "Tex"
  2324.     
  2325.     bind    'y'    <zo>    psi    "Tex"
  2326.     bind    'y'    <zos>    capPsi    "Tex"
  2327.     
  2328.     bind    'z'    <zo>    zeta    "Tex"
  2329.     
  2330.     bind    '\ '    <zo>    thin    "Tex"
  2331.     bind    '\ '    <zos>    negThin    "Tex"
  2332.     # bind    '\ '    <oz>    medium    "Tex"
  2333.     bind    '\ '    <zco>    thick    "Tex"
  2334.     bind    '\ '    <zcs>    quad    "Tex"
  2335.     bind    '\ '    <zcso>    dblQuad    "Tex"
  2336.     
  2337.     bind    ','    <zo>    lessOrEqual    "Tex"
  2338.     bind    ','    <zos>    subset    "Tex"
  2339.     # bind    ','    <oz>    subsetOrEqual    "Tex"
  2340.     bind    ','    <zco>    subscript    "Tex"
  2341.     
  2342.     bind    '.'    <zo>    greaterOrEqual    "Tex"
  2343.     bind    '.'    <zos>    superset    "Tex"
  2344.     # bind    '.'    <oz>    supersetOrEqual    "Tex"
  2345.     bind    '.'    <zco>    superscript    "Tex"
  2346.     
  2347.     bind    '/'    <zo>    divide    "Tex"
  2348.     bind    '/'    <zco>    fraction    "Tex"
  2349.     
  2350.     bind    '\;'    <zo>    ellipsis    "Tex"
  2351.     bind    '\;'    <zos>    centerDots    "Tex"
  2352.     # bind    '\;'    <oz>    verticalDots    "Tex"
  2353.     bind    '\;'    <zco>    diagonalDots    "Tex"
  2354.     
  2355.     # apostrophe:
  2356.     bind    0x27    <zco>    acuteAccent    "Tex"
  2357.     bind    0x27    <zcs>    quotes    "Tex"
  2358.     bind    0x27    <zcso>    dblQuotes    "Tex"
  2359.  
  2360.     bind    '\['    <zo>    brackets    "Tex"
  2361.     bind    '\['    <zos>    braces    "Tex"
  2362.     bind    '\['    <zco>    bigBrackets    "Tex"
  2363.     bind    '\['    <zcso>    bigBraces    "Tex"
  2364.  
  2365.     bind    '\]'    <zo>    displayStyle    "Tex"
  2366.     bind    '\]'    <zos>    textStyle    "Tex"
  2367.     # bind    '\]'    <oz>    scriptStyle    "Tex"
  2368.     bind    '\]'    <zco>    scriptscriptStyle    "Tex"
  2369.     bind    '\]'    <zcso>    bigLeftBrace    "Tex"
  2370.     
  2371.     bind    '\'    <zo>    backslash    "Tex"
  2372.     bind    '\'    <zos>    absoluteValue    "Tex"
  2373.     # bind    '\'    <oz>    setMinus    "Tex"
  2374.     bind    '\'    <zco>    bigAbsoluteValue    "Tex"
  2375.     bind    '\'    <zcs>    "oneParameter"    "Tex"
  2376.     bind    '\'    <zcso>    "twoParameters"    "Tex"
  2377.     
  2378.     bind    '`'    <zco>    graveAccent    "Tex"
  2379.     bind    '`'    <zcso>    tilde    "Tex"
  2380.     
  2381.     # Change to latexMath and latexDisplaymath, if desired:
  2382.     bind    '4'    <zco>    texMath    "Tex"
  2383.     bind    '4'    <zcso>    texDisplaymath    "Tex"
  2384.     
  2385.     bind    '5'    <zo>    infinity    "Tex"
  2386.     
  2387.     bind    '6'    <zo>    sectionMark    "Tex"
  2388.     bind    '6'    <zco>    superscript    "Tex"
  2389.     
  2390.     bind    '7'    <zo>    paragraphMark    "Tex"
  2391.     
  2392.     bind    '8'    <zo>    bullet    "Tex"
  2393.     bind    '8'    <zos>    asterisk    "Tex"
  2394.     # bind    '8'    <oz>    centerDot    "Tex"
  2395.     
  2396.     bind    '9'    <zos>    parentheses    "Tex"
  2397.     bind    '9'    <zco>    bigParentheses    "Tex"
  2398.     
  2399.     # bind    '0'    <oz>    emptySet    "Tex"
  2400.     
  2401.     bind    '-'    <zo>    similar    "Tex"
  2402.     bind    '-'    <zos>    minusOrPlus    "Tex"
  2403.     # bind    '-'    <oz>    negation    "Tex"
  2404.     bind    '-'    <zco>    subscript    "Tex"
  2405.     
  2406.     bind    '='    <zo>    notEqual    "Tex"
  2407.     bind    '='    <zos>    plusOrMinus    "Tex"
  2408.     # bind    '='    <oz>    approximate    "Tex"
  2409.     bind    '='    <zco>    bar    "Tex"
  2410.     
  2411.     bind    F5    <zo>    math    "Tex"
  2412.     bind    F5    <zos>    displaymath    "Tex"
  2413.     # bind    F5    <oz>    equation    "Tex"
  2414.     
  2415.     bind    F6    <zo>    "myArray"    "Tex"
  2416.     bind    F6    <zos>    "eqnarray"    "Tex"
  2417.     # bind    F6    <oz>    "eqnarrayStar"    "Tex"
  2418.     
  2419.     bind    F7    <zo>    "enumerate"    "Tex"
  2420.     bind    F7    <zos>    "itemize"    "Tex"
  2421.     # bind    F7    <oz>    "description"    "Tex"
  2422.     
  2423.     bind    F8    <zo>    "tabular"    "Tex"
  2424.     bind    F8    <zos>    tabbing    "Tex"
  2425.     
  2426.     bind    F9    <zo>    figure    "Tex"
  2427.     bind    F9    <zos>    table    "Tex"
  2428.     # bind    F9    <oz>    slide    "Tex"
  2429.     
  2430.     bind    F10    <zo>    verbatim    "Tex"
  2431.     bind    F10    <zos>    quote    "Tex"
  2432.     # bind    F10    <oz>    quotation    "Tex"
  2433.     bind    F10    <zco>    verse    "Tex"
  2434.     
  2435.     bind    F11    <zo>    "index"    "Tex"
  2436.     bind    F11    <zos>    "bibliography"    "Tex"
  2437.     
  2438.     bind    F12    <zo>    "general"    "Tex"
  2439.  
  2440.     # tab:
  2441.     bind    0x30    nextTabStop    "Tex"
  2442.     bind    0x30    <s>     previousTabStop    "Tex"
  2443.     
  2444. }
  2445.